package com.campus.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.campus.dao.MyFileDao;
import com.campus.entity.MyFile;

@Repository
public class MyFileDaoImpl implements MyFileDao {

	@Resource
	private SessionFactory sessionFactory;
	
	@Override
	public List<MyFile> selectList() {
		List<MyFile> list = (List<MyFile>) sessionFactory.getCurrentSession().createQuery("from MyFile").list();
		return list;
	}

	@Override
	public void add(MyFile thisClass) {
		sessionFactory.getCurrentSession().save(thisClass);
	}

	@Override
	public MyFile getById(int id) {
		MyFile myClass = (MyFile) sessionFactory.getCurrentSession().get(MyFile.class,id);
		return myClass;
	}

	@Override
	public void update(MyFile thisClass) {
		sessionFactory.getCurrentSession().update(thisClass);
	}

	@Override
	public void deleteById(int id) {
		MyFile c=new MyFile();
		c.setId(id);
		sessionFactory.getCurrentSession().delete(c);
	}





}
